package com.jqing.lib;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.jqing.lib.print.Print;

/**
 * Created by chshqiang on 15-6-16.
 * Base Fragment
 */
public abstract class BaseFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(getContentView(), null);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        initializeView(view);
        initializeData(savedInstanceState);
        setup();
    }

    protected abstract int getContentView();

    protected abstract void initializeView(View view);

    protected abstract void initializeData(Bundle savedInstanceState);

    protected abstract void setup();

    protected void toast(String msg) {
        Toast.makeText(this.getActivity(), msg, Toast.LENGTH_LONG).show();
    }

    protected void print(String o) {
        Print.m(o);
    }

    protected void error(String o) {
        Print.e(o);
    }

}
